package com.ht.service.impl;

import com.ht.domain.bo.HospitalBO;
import com.ht.domain.po.TbHospital;
import com.ht.mapper.HospitalMapper;
import com.ht.service.HospitalService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 医院表service
* @author zsq
* @description 针对表【tb_hospital】的数据库操作Service实现
* @createDate 2022-05-25 10:00:05
*/
@Service
public class HospitalServiceImpl implements HospitalService {

    @Autowired
    private HospitalMapper hospitalMapper;

    /**
     * 添加医院信息
     * @param hospitalBO 医院实体
     * @return
     */
    @Override
    public int addHospital(HospitalBO hospitalBO) {
        TbHospital hospital = new TbHospital();
        BeanUtils.copyProperties(hospitalBO,hospital);
        hospital.setHospitalStatus(0);
        return hospitalMapper.insert(hospital);
    }

    /**
     * 根据医院id修改医院审核状态
     * @param hospitalId 医院id
     * @param hospitalStatus 审核状态
     * @return
     */
    @Override
    public int updateHospitalStatusByHospitalId(Long hospitalId, Integer hospitalStatus) {
        TbHospital hospital = hospitalMapper.selectById(hospitalId);
        hospital.setHospitalStatus(hospitalStatus);
        return hospitalMapper.updateById(hospital);
    }
}




